﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Pro.DataServiceInterface
{
    public interface IBaseService<T>
         where T : class
    {
        /// <summary>
        /// 根据Id取对象
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        T Get(int id);

        /// <summary>
        /// 新增数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        T Add(T model);

        /// <summary>
        /// 批量新增
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        IEnumerable<T> AddRange(IEnumerable<T> list);

        /// <summary>
        /// 如果不存在会新增，存在就更新数据
        /// </summary>
        /// <param name="model"></param>
        void Update(T model);

        /// <summary>
        /// 标注为删除
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        void Delete(T model);

        /// <summary>
        /// 还原
        /// </summary>
        /// <param name="model"></param>
        void Restore(T model);

        /// <summary>
        /// 彻底删除
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        T ShiftDelete(T model);

        /// <summary>
        /// 取得所有数据，延迟执行
        /// </summary>
        /// <returns></returns>
        IQueryable<T> GetQueryable();

        /// <summary>
        /// 初始化操作，比如初始化一些默认数据
        /// </summary>
        void Initialize();

        void Commit();
    }
}
